package com.unbox.admin.controller;

import com.unbox.admin.entity.File;
import com.unbox.admin.service.IUploadFileService;
import com.unbox.common.response.UnboxResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 上传文件
 */
@RestController
@RequestMapping(value = "/v1/file")
public class UploadFileController {

    @Autowired
    IUploadFileService uploadFileService;

    /**
     *  上传图片
     */
    @PostMapping(value = "/uploadFileImg")
    public UnboxResponse<File> uploadFile(@RequestParam(value = "file") MultipartFile file) {
        File result = uploadFileService.uploadFile(file);
        return new UnboxResponse<>(result);
    }
}
